home *** CD-ROM | disk | FTP | other *** search
- // (C) Copyright Microsoft Corp. 1991. All rights reserved.
- //
- // You have a royalty-free right to use, modify, reproduce and
- // distribute the Sample Files (and/or any modified version) in
- // any way you find useful, provided that you agree that
- // Microsoft has no warranty obligations or liability for any
- // Sample Application Files which are modified.
-
-
- /****************************************************************************
-
- MODULE : DIALOGS.C
-
- PURPOSE : This module contains the dialog box procedures used in the application playvfw.
-
- FUNCTIONS :
- ButtonBarProc
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 8/15/93
-
- ****************************************************************************/
-
- #include "windows.h"
- #include <stdlib.h>
- #include "playvfw.h"
- #include "proto.h"
- #include "mmsystem.h"
- #include <digitalv.h>
- #include <stdio.h>
- #include <time.h>
-
-
-
- /****************************************************************************
-
- FUNCTION : ButtonBarProc( HANDLE, unsigned, WORD, LONG )
-
- PURPOSE : The ButtonBarProc is the dialog box procedure for the Video Playback Control. The Video
- Playback Control is used to navigate through a Video for Windows file. The control supports
- play, pause, rewind, step reverse, step forward, stop.
-
- COMMENTS : Due to palette problems I have designed the control so that when you play a video it hides
- the video buttons and when you stop the video it shows them again. It would be very difficult
- to mix palettes between a instructional video and a video displayed in the buttons.
-
- HISTORY : Created by Steven Molstad 8/10/93.
-
- ****************************************************************************/
-
- BOOL FAR PASCAL _export ButtonBarProc( hDlg, message, wParam, lParam )
- HWND hDlg;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
-
-
-
- static BOOL bIsPaused;
- static BOOL bPlayClicked;
-
-
- switch (message)
- {
- case WM_INITDIALOG:
-
- // intialize the puased variable to FALSE since when the control is created the video is
- // stopped not paused.
-
- bIsPaused=FALSE;
- bPlayClicked=FALSE;
- break;
-
-
-
- case WM_COMMAND:
- {
-
- switch (wParam)
- {
- case ID_PLAY:
-
- bPlayClicked=TRUE;
-
- // when the play button is pressed we want to hide the edit window and show the
- // video window.
-
- ShowWindow( hWndEdit, SW_HIDE );
- ShowWindow(lpDevice9->hWnd, SW_SHOWNORMAL );
-
- // we also want to hide all the buttons to avoid any nasty palette problems.
-
- ShowWindow( lpDevice1->hWnd, SW_HIDE );
- ShowWindow( lpDevice2->hWnd, SW_HIDE );
- ShowWindow( lpDevice3->hWnd, SW_HIDE );
- ShowWindow( lpDevice4->hWnd, SW_HIDE );
-
- // If the video is paused we want to resume the video from where it left off.
- // If the video was stopped then we want to start playing from the begining.
-
- if (bIsPaused)
- {
-
- ResumeVFWFile(lpDevice9->wDeviceID);
- bIsPaused=FALSE;
- }
- else
- {
-
- PlayVFWFile(hWndMain,lpDevice9->hWnd,lpDevice9->wDeviceID);
- }
- break;
-
- case ID_STOP:
-
- bPlayClicked=FALSE;
-
- // Stop the Video. Hide the video window and show all the buttons to avoid any
- // nasty palette changes.
-
- StopVFWFile(lpDevice9->wDeviceID);
-
- ShowWindow(lpDevice9->hWnd, SW_HIDE );
- ShowWindow(lpDevice1->hWnd, SW_SHOWNORMAL );
- ShowWindow(lpDevice2->hWnd, SW_SHOWNORMAL );
- ShowWindow(lpDevice3->hWnd, SW_SHOWNORMAL );
- ShowWindow(lpDevice4->hWnd, SW_SHOWNORMAL );
- ShowWindow( hWndButtonBar, SW_HIDE );
-
- break;
-
- case ID_PAUSE:
-
- if (bPlayClicked)
- {
-
- // If the video is paused and the user presses pause resume the video from where it
- // left off. Otherwise pause the video.
-
- if (bIsPaused)
- {
-
- ResumeVFWFile(lpDevice9->wDeviceID);
- bIsPaused=FALSE;
- }
- else
- {
-
- PauseVFWFile(lpDevice9->wDeviceID);
- bIsPaused=TRUE;
- }
- }
- break;
-
- case ID_REWIND:
- if (bPlayClicked)
- {
- // Rewind the video to the begining.
-
- SeekVFWToStart(lpDevice9->wDeviceID);
- }
- break;
-
- case ID_FORWARD:
- if (bPlayClicked)
- {
- // Step the Video forward by 5 frames. You can change this value if 5 frames is to
- // little.
-
- StepVFW(lpDevice9->wDeviceID,5);
- }
- break;
-
- case ID_BACK:
-
- if (bPlayClicked)
- {
-
- // Step the video backwards by 1 frame. Video for Windows does not give you any
- // additional control to step backwards more than one frame. To achieve this you
- // would need to keep track of the position or get the current position and then
- // seek back so many frames. I leave this as an exercise for the reader.
-
- StepVFWReverse(lpDevice9->wDeviceID);
-
- break; }
- }
-
- }
- break;
-
- default:
- return FALSE;
- }
-
- return FALSE;
- }